package stu.kurs;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ResourceBundle;

public class CustomDateFormat {
	
	private static final String FORMAT_TIME = "HH:mm";
	private static final String FORMAT_DATE = "dd.MM.yyyy";
	private static final SimpleDateFormat sdft = new SimpleDateFormat(FORMAT_TIME);
	private static final SimpleDateFormat sdfd = new SimpleDateFormat(FORMAT_DATE);
	
	public static Date getTime(String time) throws ParseException{
		Date d = sdft.parse(time);
		return d;
	}
	
	public static Date getDate(String date) throws ParseException{
		Date d = sdfd.parse(date);
		return d;
	}
	
	@SuppressWarnings("deprecation")
	public static String convertDate(Date date){
		StringBuilder sb = new StringBuilder();
		ResourceBundle rb = ResourceBundle.getBundle("messages");
		sb.append(date.getDate() + " ");
		sb.append(rb.getString("calendar.month." + date.getMonth()) + " ");
		sb.append((date.getYear() + 1900) + ", " + sdft.format(date));
		return sb.toString();
	}
}

